<template>

	<view class="header">
		<view class="uesr">
			<view class="top-xh">
				<view class="h2">
					个人中心
				</view>
				<navigator class="pic" url="../../tabbar-5-detial/notice/notice">
					
					<image src="/static/cy-my/xiaoxi.png" style="width: 40rpx;" mode="widthFix"></image>
				</navigator>
			</view>
			<view class="fot-xh">
			<!-- 	navigator不用加vue了 -->
				<navigator url="/pages/detailMessage/detailMessage?id=123&name=mcl" hover-class="none">
					<view class="pic">
						<image :src="user.avatarUrl" style="width: 130rpx;" mode="widthFix">
						</image>
					</view>
					<view class="txt" >
						
						<view class="name" >
							<view class="h3">
								{{user.nickname}}
							</view>
							<view class="phone">
								ID:{{user.id}}
							</view>
						</view>
					</view>
				</navigator>
			</view>
		</view>
		<view class="about">
			<view class="m-a1">
				<navigator url="../../login/login" hover-class="none">
					<view class="pic">
						<image src="/static/cy-my/tianjia.png" style="width: 76rpx;" mode="widthFix"></image>
					</view>
					<view class="txt" v-if=ifLogin>
						<text class="s1">点击切换登录用户</text>
						<text>用户注册时间：{{user.createTime}}</text>

					</view>
					<view class="txt" v-else>
						<text class="s1">点击登录</text>
						<text>欢迎光临gualiguali！</text>
					
					</view>
					
				</navigator>
			</view>
		</view>
		<view class="ul-list1-xh">
			<view class="li">
				<navigator url="../../tabbar-5-detial/check/check" hover-class="none">
					<view class="pic">
						<image src="/static/cy-my/qianbao.png" style="width: 40rpx;" mode="widthFix"></image>
					</view>
					<view class="txt">
						<text>审核视频</text>
					</view>
				</navigator>
			</view>
			<view class="li">
				<navigator url="../../statisticsInformation/statisticsInformation" hover-class="none">
					<view class="pic">
						<image src="/static/cy-my/dingdan.png" style="width: 35rpx;" mode="widthFix"></image>
					</view>
					<view class="txt">
						<text>数据统计</text>
					</view>
				</navigator>
			</view>

			<view class="li">
				<navigator url="../../tabbar-5-detial/back/back" hover-class="none">
					<view class="pic">
						<image src="/static/cy-my/yijian.png" style="width: 35rpx;" mode="widthFix"></image>
					</view>
					<view class="txt">
						<text>意见反馈</text>
					</view>
				</navigator>
			</view>
			<view class="li">
				<navigator url="../../tabbar-5-detial/about/about" hover-class="none">
					<view class="pic">
						<image src="/static/cy-my/guanyhu.png" style="width: 35rpx;" mode="widthFix"></image>
					</view>
					<view class="txt">
						<text>关于我们</text>
					</view>
				</navigator>
			</view>
			<view class="li">
				<navigator url="../../tabbar-5-detial/private/private" hover-class="none">
					<view class="pic">
						<image src="/static/cy-my/yinsi.jpg" style="width: 35rpx;" mode="widthFix"></image>
					</view>
					<view class="txt" style="border-bottom: none;">
						<text>隐私政策</text>
					</view>
				</navigator>
			</view>
		</view>
	</view>
</template>


<script>
	export default {

onLoad(){
		  console.log("进入5页面")
		  console.log("当前id:"+this.$store.state.id)
		  console.log("当前token:"+this.$store.state.token)
		  uni.request({
		  	  	method:'GET',
		  	  	url:"http://47.97.114.13:8080/api/user/my",
		  	  	header: {
		  	  	    "Authorization": this.$store.state.token,
		  	  	  },
		  	  })					  
		  	  .then(res => {
				  console.log(res);
		  		  console.log(res[1].data.data);
				  if(res[1].data.data.id!=null)
				  {
					  console.log("有用户")
					  this.ifLogin=true
				  }
				  //获取信息
				  this.user.id = res[1].data.data.id;
				  this.user.nickname = res[1].data.data.nickname;
				  this.user.avatarUrl = res[1].data.data.avatarUrl;
				  this.user.introduction = res[1].data.data.introduction;
				  this.user.gender = res[1].data.data.gender;
				  this.user.createTime = res[1].data.data.createTime;
		  	  })
	      },
		  onPullDownRefresh(){
		  		  console.log("刷新5页面")
		  		  console.log("当前id:"+this.$store.state.id)
		  		  console.log("当前token:"+this.$store.state.token)
		  		  uni.request({
		  		  	  	method:'GET',
		  		  	  	url:"http://47.97.114.13:8080/api/user/my",
		  		  	  	header: {
		  		  	  	    "Authorization": this.$store.state.token,
		  		  	  	  },
		  		  	  })					  
		  		  	  .then(res => {
		  				  console.log(res);
		  		  		  console.log(res[1].data.data);
		  				  if(res[1].data.data.id!=null)
		  				  {
		  					  console.log("有用户")
		  					  this.ifLogin=true
		  				  }
		  				  //获取信息
		  				  this.user.id = res[1].data.data.id;
		  				  this.user.nickname = res[1].data.data.nickname;
		  				  this.user.avatarUrl = res[1].data.data.avatarUrl;
		  				  this.user.introduction = res[1].data.data.introduction;
		  				  this.user.gender = res[1].data.data.gender;
		  				  this.user.createTime = res[1].data.data.createTime;
		  		  	  })
					  
					  uni.stopPullDownRefresh()
		  	      },
		  data() {
		    return {
				title: 'Hello',
				ifLogin:false,
		      user: {
		  		id:"",
		        nickname: "未登录昵称",
		        avatarUrl: "https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/logo.png",
		        introduction:'',
		  		gender: "男",
		        createTime:'',
		      },
		      editable: false
		    };
		  },

		methods: {
			gotoDetailMessage(){
				uni.navigateTo({
					url:'detailMessage'
				})
			}

		}
	}
</script>

<style>
		@import url("cy-my.css");
	.content {
		text-align: center;
		height: 400upx;
		margin-top: 200upx;
	}
</style>
